#include <RGB.h>
#include <RGBMatrix.h>
#include <MultiMatrix.h>

/**
 * Some tests to make sure that MultiMatrix is working, and to demonstrate its use.
 * If this doesn't work for you, perhaps you have connected your boards in a different 
 * arrangement than I have. If this is the case, please correct the parameters to MultiMatrix.begin().
 * (See documentation for what they mean.)
 */

//Define how many LED matrices are connected to create the frame.
const int NUM_BOARDS = 4;

// make this number smaller to make the tests go faster
const int DELAY = 500;

void setup()
{
    MultiMatrix.begin(0, NORTH, 1, NORTH, 2, SOUTH, 3, SOUTH);
    Serial.begin(9600);
}

void show()
{
  MultiMatrix.display();
  delay(DELAY);
  MultiMatrix.clear();
}

// This should light the pixel in the top left corner of each matrix
// If it doesn't, you have passed the NORTH/SOUTH arguments wrong.
void testFillPixel()
{
  delay(DELAY);
  
  const unsigned int row = 0;
  const unsigned int col = 0;
  
  MultiMatrix.fillPixel(row, col, RED);
  show();
  
  MultiMatrix.fillPixel(row + NUM_ROWS, col, RED);
  show();
  
  MultiMatrix.fillPixel(row + NUM_ROWS, col + NUM_COLUMNS, RED);
  show();
  
  MultiMatrix.fillPixel(row, col + NUM_COLUMNS, RED);
  show();
}

void testFillColumn() 
{
  for (int i = 0; i < MULTI_NUM_COLUMNS; i++) 
  {
    MultiMatrix.fillColumn(i, TEAL);
    show();
  }
}

void testFillRow()
{
  for (int i = 0; i < MULTI_NUM_ROWS; i++)
  {
     MultiMatrix.fillRow(i, ORANGE);
     show(); 
  }
}

void testFillScreen()
{
    MultiMatrix.fillScreen(GREEN);
    show();
    
    MultiMatrix.fillScreen(BLUE);
    show();
}

void loop()
{
  testFillPixel();
  testFillColumn();
  testFillRow();
  testFillScreen();
}

